<template>
  <div 
    class="tag-card" 
    :class="{ 'selected': selected }"
    @click="$emit('click')"
  >
    <div class="tag-icon">
      <img :src="tag.icon" :alt="tag.name" />
    </div>
    <div class="tag-name">{{ tag.name }}</div>
    <div v-if="selected" class="check-icon">✓</div>
    <div class="lightning-icon">⚡</div>
  </div>
</template>

<script setup>
defineProps({
  tag: {
    type: Object,
    required: true
  },
  selected: {
    type: Boolean,
    default: false
  }
})

defineEmits(['click'])
</script>

<style scoped>
.tag-card {
  width: 100px;
  height: 100px;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 2px solid #f1f3f4;
  overflow: hidden;
  margin: 0 auto;
}

.tag-card:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.tag-card.selected {
  border-color: #ff6b9d;
  background: linear-gradient(135deg, #ff6b9d 0%, #c44569 100%);
  color: white;
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 8px 30px rgba(255, 107, 157, 0.4);
}

.tag-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  padding: 8px;
}

.tag-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.tag-card.selected .tag-icon {
  background: rgba(255, 255, 255, 0.2);
}

.tag-card.selected .tag-icon img {
  filter: brightness(0) invert(1) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.tag-name {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  color: #495057;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-card.selected .tag-name {
  color: white;
}

.check-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: #28a745;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
  border: 2px solid white;
}

.lightning-icon {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 20px;
  height: 20px;
  background: #ffc107;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  box-shadow: 0 2px 6px rgba(255, 193, 7, 0.3);
  border: 2px solid white;
}

.tag-card.selected .lightning-icon {
  background: rgba(255, 255, 255, 0.3);
  color: white;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .tag-card {
    width: 90px;
    height: 90px;
  }
  
  .tag-icon {
    width: 44px;
    height: 44px;
    margin-bottom: 6px;
  }
  
  .tag-name {
    font-size: 12px;
    max-width: 70px;
  }
}

@media (max-width: 768px) {
  .tag-card {
    width: 80px;
    height: 80px;
  }
  
  .tag-icon {
    width: 36px;
    height: 36px;
    margin-bottom: 4px;
  }
  
  .tag-name {
    font-size: 11px;
    max-width: 60px;
  }
  
  .check-icon {
    width: 18px;
    height: 18px;
    font-size: 10px;
  }
  
  .lightning-icon {
    width: 16px;
    height: 16px;
    font-size: 8px;
  }
}

@media (max-width: 480px) {
  .tag-card {
    width: 70px;
    height: 70px;
  }
  
  .tag-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 3px;
  }
  
  .tag-name {
    font-size: 10px;
    max-width: 50px;
  }
  
  .check-icon {
    width: 16px;
    height: 16px;
    font-size: 9px;
  }
  
  .lightning-icon {
    width: 14px;
    height: 14px;
    font-size: 7px;
  }
}
</style>
